const { list } = require('./mock')


module.exports = app => {
	app.get('/api/list', (req, res) => {
		const { pageCode = 1, pageSize = 8 } = req.query;

		if(pageCode * pageSize <= list.length) {
			res.send({
				code: 200,
				data: list.slice((pageCode - 1) * pageSize, pageCode * pageSize),
				total: list.length,
				message: '请求' + pageSize +'条数据成功'
			})
		} else {
			res.send({
				code: 201,
				data: null,
				message: '没有更多数据了'
			})
		}
	})
}